package cn.Collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;

public class CollectionDemo3 {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("yy");
        c.add("tyy");
        c.add("gg");
        c.add("Tov");
        //集合转为数组
        Object[] os = c.toArray();
        for (Object o : os){
            System.out.println(o);
        }
        String[] arr = c.toArray(new String[5]);
        for (String s:arr){
            System.out.println(s);
        }

        //遍历集合
        c.forEach( s ->{ System.out.println(s); });
        c.forEach(System.out::println);
    }
}
